***********************************************************************
*** Replication Code for Reweighting Sample Table A5-A9 in appendix ***
*** Title: Reneging on Alliances: Experimental Evidenc 			    ***
*** Authors: Weifang Xu, Kai Quek, and Mark Souva           	    ***
*** Version: August 23, 2023                        			    ***
***********************************************************************

/// Stata version: 17.0 ///
clear all
/* ssc install estout // if not yet installed */
cd "/Users/victorxu/Desktop/side project/military alliance /research and politics/data replication" // change to your own working directory

/* Import the main dataset that contains all survey responses */
insheet using "data for reweighting.csv"




/*** Results Reported in the Appendix ***/
** Appendix Table A5-A9: Average Treatment Effects After Reweighting Sample
// Generate the dummy variables required for the analysis
gen biatti =.
replace biatti = 1 if x7attitude >= 5 & x7attitude <=7
replace biatti = 0 if x7attitude >= 1 & x7attitude <=4

gen age1834 = .
replace age1834 = 1 if age >= 18 & age <= 34
replace age1834 = 0 if age >= 34 & age <= 999

gen female = .
replace female = 1 if gender ==2
replace female = 0 if gender ==1

gen college = .
replace college = 1 if educ >=5 & educ <=8
replace college = 0 if educ >=1 & educ <=4


** destring pid, generate(pid_2) ignore(`"NA"')
** tab pid_2

destring pid_d, generate(pid_d1) ignore(`"NA"')
destring pid_r, generate(pid_r1) ignore(`"NA"')
destring pid_n, generate(pid_n1) ignore(`"NA"')



gen democrat = .
replace democrat = 1 if pid_d1 ==1 | pid_d1==2 | pid_n1 ==2 
replace democrat = 0 if pid_r1 ==1| pid_r1 ==2| pid_n1 == 1 | pid_n1 ==3

gen vignette = .
replace vignette = 1 if treat == 1 | treat == 2 | treat == 3 | treat == 4 | treat == 5
replace vignette = 0 if treat == 6

// Compute the ATEs after the sample reweighting (Table A5)
ebalance age1834 female college democrat , manualtargets(.2978 .5156 .3225 0.470) 
	// Note 1: see "ebalance.ado" for the source code
	// Note 2: the weights are set according to those reported in Table A5
// Replicate Table A6
svyset [pweight = _webal]
// large casualties vs. control; p = 0.01
svy: reg biatti vignette if (treat == 1 | treat == 6) 
// low prospect of victory vs. control; p = 0.145
svy: reg biatti vignette if (treat == 2 | treat == 6) 
// economic impact vs. control; p= 0.50
svy: reg biatti vignette if (treat == 5 | treat == 6) 
// UN mediation vs. control; p = 0.45
svy: reg biatti vignette if (treat == 3 | treat == 6) 
// economic sanction vs. control p = 0.18
svy: reg biatti vignette if (treat == 4 | treat == 6)


// Replicate Table A7
** x7attitide (7 point- scale of approval) 
svyset [pweight = _webal]
// large casualties vs. control; p = 0.007
svy: reg x7attitude vignette if (treat == 1 | treat == 6)
// low prospect of victory vs. control; p = 0.09
svy: reg x7attitude vignette if (treat == 2 | treat == 6) 
// economic impact vs. control; p= 0.90
svy: reg x7attitude vignette if (treat == 5 | treat == 6)
// UN mediation vs. control; p = 0.33
svy: reg x7attitude vignette if (treat == 3 | treat == 6)
// economic sanction vs. control p = 0.18
svy: reg x7attitude vignette if (treat == 4 | treat == 6)

// Replicate Table A8
** military reputation (5 point scale) 
destring repu1, generate(repu1_1) ignore(`"NA"')
svyset [pweight = _webal]
// large casualties vs. control; p = 0.70
svy: reg repu1_1 vignette if (treat == 1 | treat == 6)
// low prospect of victory vs. control; p = 0.62
svy: reg repu1_1 vignette if (treat == 2 | treat == 6)
// economic impact vs. control; p= 0.82
svy: reg repu1_1 vignette if (treat == 5 | treat == 6)
// UN mediation vs. control; p = 0.098
svy: reg repu1_1 vignette if (treat == 3 | treat == 6)
// economic sanction vs. control p = 0.26
svy: reg repu1_1 vignette if (treat == 4 | treat == 6)

// Replicate Table A9
** non-military reputation 

destring repu2, generate(repu2_1) ignore(`"NA"')
svyset [pweight = _webal]
// large casualties vs. control; p = 0.16
svy: reg repu2_1 vignette if (treat == 1 | treat == 6)
// low prospect of victory vs. control; p = 0.62
svy: reg repu2_1 vignette if (treat == 2 | treat == 6)
// economic impact vs. control; p= 0.90
svy: reg repu2_1 vignette if (treat == 5 | treat == 6)
// UN mediation vs. control; p = 0.08
svy: reg repu2_1 vignette if (treat == 3 | treat == 6)
// economic sanction vs. control p = 0.10
svy: reg repu2_1 vignette if (treat == 4 | treat == 6)
